<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta content="initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport"/>
    <title>
        Add Graphics to a SceneView | Sample | ArcGIS API for JavaScript 4.18
    </title>

    <link
            rel="stylesheet"
            href="https://js.arcgis.com/4.21/esri/themes/dark/main.css"
    />
    <script src="https://js.arcgis.com/4.21/"></script>

    <style>
        html,
        body,
        #viewDiv {
            padding: 0;
            margin: 0;
            height: 100%;
            width: 100%;
        }
    </style>

    <script>
        require(["esri/Map", "esri/views/SceneView", "esri/layers/support/TileInfo","esri/layers/WebTileLayer"],
            (Map, SceneView, TileInfo,WebTileLayer) => {
                const wkid=4490;

                //定义瓦片结构,仅适用于天地图4490 瓦片
                let tileInfo = new TileInfo({
                    dpi: 96,
                    rows: 256,
                    cols: 256,
                    compressionQuality: 0,
                    origin: {
                        x: -180,
                        y: 90,
                    },
                    spatialReference: {
                        wkid: wkid,
                    },
                    lods: [
                        {level: 0, resolution: 0.703125, scale: 295829355.454566},
                        {level: 1, resolution: 0.3515625, scale: 147914677.727283},
                        {level: 2, resolution: 0.17578125, scale: 73957338.863641},
                        {level: 3, resolution: 0.087890625, scale: 36978669.431821},
                        {level: 4, resolution: 0.0439453125, scale: 18489334.71591},
                        {level: 5, resolution: 0.02197265625, scale: 9244667.357955},
                        {level: 6, resolution: 0.010986328125, scale: 4622333.678978},
                        {level: 7, resolution: 0.0054931640625, scale: 2311166.839489},
                        {level: 8, resolution: 0.00274658203125, scale: 1155583.419744},
                        {level: 9, resolution: 0.001373291015625, scale: 577791.709872},
                        {level: 10, resolution: 0.0006866455078125, scale: 288895.854936},
                        {level: 11, resolution: 0.00034332275390625, scale: 144447.927468},
                        {level: 12, resolution: 0.000171661376953125, scale: 72223.963734},
                        {level: 13, resolution: 8.58306884765625e-5, scale: 36111.981867},
                        {level: 14, resolution: 4.291534423828125e-5, scale: 18055.990934},
                        {level: 15, resolution: 2.1457672119140625e-5, scale: 9027.995467},
                        {level: 16, resolution: 1.0728836059570313e-5, scale: 4513.997733},
                        {level: 17, resolution: 5.3644180297851563e-6, scale: 2256.998867},
                        {level: 18, resolution: 0.000002682209014892578, scale: 1128.499433},
                    ],
                });

                let tiledLayer = new WebTileLayer({
                    urlTemplate:
                        'http://{subDomain}.tianditu.com/img_c/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=img&STYLE=default&FORMAT=tiles&TILEMATRIXSET=c&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=886d6ea429c3326f87bde14b36482e12',
                    subDomains: ['t0'],
                    tileInfo: tileInfo,
                    spatialReference: {
                        wkid:wkid
                    }
                });


                var map = new Map({
                    spatialReference : {
                        wkid : wkid
                    }
                });

                var mapview = new SceneView ({
                    container: "viewDiv",
                    map: map,
                    spatialReference : {
                        wkid : wkid
                    },
                });

                map.add(tiledLayer);

            });
    </script>
</head>

<body>
<div id="viewDiv"></div>
</body>
</html>
